﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using Metro.Admin.BusinessEntities;
using Metro.Admin.DataAccess;
using Metro.Admin.Services;      

namespace Metro.Admin.Views
{
    public class CitiesCountriesPresenter : Presenter<ICitiesCountries>
    {

        private IAdminService _adminService;
        public CitiesCountriesPresenter([ServiceDependency] IAdminService adminService)
        {
            _adminService = adminService;
        }

        public override void OnViewLoaded()
        {
            List<Country> countries =null;
            ICollection<City> cities = null;
  
            countries = _adminService.GetCountries();
            View.ShowCountries(countries);

            cities = _adminService.GetCities();
            View.ShowCities(cities);           
        }

        public override void OnViewInitialized()
        {
            // TODO: Implement code that will be executed the first time the view loads
        }

        //public List<Country> GetCountries()
        //{
        //    List<Country> countries = null;
        //    countries = _adminService.GetCountries();
        //    return countries;
        //}

        public void CreateCountry(Country country)
        {
            _adminService.CreateCountry(country);
        }

        public void UpdateCountry(Country country)
        {
            _adminService.UpdateCountry(country);
        }

        public void DeleteCountry(Country country)
        {
            _adminService.DeleteCountry(country);
        }

        public void UpdateCity(City city)
        {
            _adminService.UpdateCity(city);
        }

        public void CreateCity(City city, string idCountry)
        {
            _adminService.CreateCity(city, idCountry);
        }

        public void DeleteCity(City city)
        {
            _adminService.DeleteCity(city);
        }


    }
}




